var engine = require('../scripts/network/MatchvsEngine');
var player = require('../scripts/network/playerData');
var gameData = require('../scripts/network/gameData');
var getRoomID;
cc.Class({
    extends: cc.Component,

    properties: {
        labelLog: cc.Label,
        joinButton: cc.Button,
    },

    onLoad: function () {
        this.joinButton.node.on('click',this.joinRoon,this);
        cc.bb.log = this;
    },

    updataItem: function (roomName, gamePlayer, roomID) {
        gameData.roomInfo.roomName = roomName;
        gameData.roomInfo.roomID = roomID;
        getRoomID = roomID;
         var Name = "房间名:";
         var number = "      人数:";
         var message = Name + roomName + number + gamePlayer ;
        // console.log(roomName);
         console.log(message);
        console.log(roomName + '   ' + gamePlayer);
        this.labelLog.string = message;
        if(gamePlayer >= 3){
            this.joinButton.active = false;
        }
    },

    joinRoon: function () {
        console.log("joinRoom");
        cc.log(getRoomID,player.presentPlayer.name);
        var result = engine.prototype.joinRoom(getRoomID,player.presentPlayer.name);
        console.log(result);
    },
  
});
